#coding=gbk
if __name__ == '__main__':
    print ("auto cue")
    key='    TITLE "'
    in_filename = r'E:\cd03\CDImage.ape.cue'
    out_filename = in_filename.replace('cue', 'new.cue')
    in_file = open(in_filename, 'r')
    out_file = open(out_filename, 'w')
    index = 1
    for line in in_file:
        if line.find(key)!=-1 :
            print (line,end='')
            tmp = '    TITLE "{0:02}.'.format(index)
            newline = line.replace(key, tmp)
            print (newline,end='')
            out_file.write(newline)
            index = index+1
        else:
            out_file.write(line)
            
    
    print ('end')

            